home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / Aberrator 3.0 / Install Aberrator 3.0.exe / Install Aberrator 3.0.dxr / 00003_MUI-Engine2.ls < prev    next >
Encoding:
Text File  |  2007-04-19  |  11.9 KB  |  357 lines

  1. global gMUIObj, gMUIGUIVars
  2.  
  3. on displayMUIDialog winProps, iconLi, NameLi, EnabLi, ElemLi, xyLi, TextLi, attrLi, valuLi, groupLi
  4.   gMUIObj = new(xtra("MUI"))
  5.   if not objectp(gMUIObj) then
  6.     alert("Couldn't create MUI-Object.")
  7.     exit
  8.   end if
  9.   returnSubst = "¬ù"
  10.   gMUIGUIVars = [#MUIOutputLi: [:], #MUIItemsLi: [], #MUIWidgetsLi: [], #radioGroupWidgets: [], #modal: 1, #aString: EMPTY]
  11.   groupsLi = duplicate(groupLi)
  12.   gMUIGUIVars[#radioGroupWidgets] = duplicate(groupLi)
  13.   MuiWindowProps = GetWindowPropList(gMUIObj)
  14.   MuiWindowProps[#type] = winProps[1]
  15.   MuiWindowProps[#mode] = winProps[2]
  16.   MuiWindowProps[#closeBox] = winProps[3]
  17.   MuiWindowProps[#callback] = winProps[4]
  18.   if winProps.count >= 5 then
  19.     modalDlog = winProps[5]
  20.   else
  21.     modalDlog = 1
  22.   end if
  23.   MuiWindowProps[#modal] = modalDlog
  24.   gMUIGUIVars[#modal] = modalDlog
  25.   MuiWindowProps[#name] = TextLi[#titleBar]
  26.   if voidp(MuiWindowProps.name) then
  27.     MuiWindowProps.name = getaProp(TextLi, #Titelleiste)
  28.   end if
  29.   muiWinWid = xyLi[#BreiteF]
  30.   muiWinHgt = xyLi[#HoeheF]
  31.   xPos = xyLi[#PositionX]
  32.   yPos = xyLi[#PositionY]
  33.   if (xPos = #z) or (yPos = #z) then
  34.     xPos = getWindowCenterH() - (muiWinWid / 2)
  35.     yPos = getWindowCenterV() - (muiWinHgt / 2)
  36.   end if
  37.   if float((the environment)[#productVersion]) > 8.0 then
  38.     MuiWindowProps[#xPosition] = xPos
  39.     MuiWindowProps[#yPosition] = yPos
  40.   else
  41.     MuiWindowProps[#xPosition] = yPos
  42.     MuiWindowProps[#yPosition] = xPos
  43.   end if
  44.   MuiWindowProps[#width] = muiWinWid
  45.   MuiWindowProps[#height] = muiWinHgt
  46.   winOpen = [#value: 0, #type: #WindowBegin, #Attributes: [], #title: "winOpen", #tip: "tip", #width: muiWinWid, #height: muiWinHgt, #enabled: 1]
  47.   groupVOpen = [#value: 0, #type: #GroupVBegin, #Attributes: [], #title: "groupVOpen", #tip: "tip", #width: muiWinWid, #height: muiWinHgt, #enabled: 1]
  48.   groupVClose = [#value: 0, #type: #GroupVEnd, #Attributes: [], #title: "groupVClose", #tip: "tip", #width: muiWinWid, #height: muiWinHgt, #enabled: 1]
  49.   winClose = [#value: 0, #type: #WindowEnd, #Attributes: [], #title: "winClose", #tip: "tip", #width: muiWinWid, #height: muiWinHgt, #enabled: 1]
  50.   gMUIGUIVars[#MUIItemsLi] = [winOpen]
  51.   gMUIGUIVars[#MUIWidgetsLi] = []
  52.   xPosList = xyLi[#xListe]
  53.   yPosList = xyLi[#yListe]
  54.   widthList = xyLi[#bListe]
  55.   heigtList = xyLi[#hListe]
  56.   alignList = xyLi[#aListe]
  57.   styleList = xyLi[#pListe]
  58.   textList = TextLi[#inscription]
  59.   if voidp(textList) then
  60.     textList = TextLi[#Beschriftung]
  61.   end if
  62.   FinetuningY_Pixel_Mac = [#d: 1, #b: 1, #s: -1, #c: 1, #r: 1, #e: -1, #p: 1, #G: 4, #i: 1, #H: 8, #V: 1]
  63.   FinetuningY_Pixel_Win = [#d: 0, #b: 0, #s: -3, #c: 0, #r: 0, #e: 0, #p: 0, #G: 3, #i: 0, #H: 0, #V: 0]
  64.   if the machineType = 256 then
  65.     minusPix = FinetuningY_Pixel_Win
  66.   else
  67.     minusPix = FinetuningY_Pixel_Mac
  68.   end if
  69.   countCRPG = 0
  70.   countE = 0
  71.   countImg = 0
  72.   countBtn = 0
  73.   countImgBeforeBtn = 0
  74.   closeGroupAtWidgetNum = 0
  75.   repeat with i = 1 to ElemLi.count
  76.     widgetName = NameLi[i]
  77.     typ = ElemLi[i]
  78.     if (typ = #r) and (count(groupsLi) > 0) and (closeGroupAtWidgetNum = 0) then
  79.       group = getPropAt(groupsLi, 1)
  80.       radios = groupsLi[1]
  81.       closeGroupAtWidgetNum = getLast(radios)
  82.       add(gMUIGUIVars[#MUIItemsLi], groupVOpen)
  83.       deleteProp(groupsLi, group)
  84.     end if
  85.     props = duplicate(getEmptyMUIPropList(typ))
  86.     props[#name] = widgetName
  87.     props[#realNum] = i - countImg
  88.     if ilk(EnabLi, #propList) then
  89.       props[#enabled] = EnabLi[widgetName]
  90.     else
  91.       props[#enabled] = EnabLi[i]
  92.     end if
  93.     props[#locH] = xPosList[i]
  94.     y = yPosList[i] - minusPix[typ]
  95.     if ((typ = #e) or (typ = #s)) and (styleList[i] = #tiny) and (the machineType <> 256) then
  96.       y = y + 1
  97.     end if
  98.     props[#locV] = y
  99.     props[#width] = widthList[i]
  100.     H = heigtList[i]
  101.     if (typ = #d) or (typ = #b) then
  102.       countBtn = countBtn + 1
  103.     end if
  104.     if the machineType = 256 then
  105.       if ((typ = #d) or (typ = #b)) and (H = 20) then
  106.         H = H + 3
  107.       else
  108.         if typ = #G then
  109.           attr = attrLi.getProp(i)
  110.           styleAttr = attr[#sliderStyle]
  111.           if styleAttr = [#ticks] then
  112.             H = 30
  113.           end if
  114.         end if
  115.       end if
  116.     end if
  117.     props[#height] = H
  118.     if getOne([#r, #c, #p, #G], typ) then
  119.       countCRPG = countCRPG + 1
  120.       if ilk(valuLi, #propList) then
  121.         props[#value] = valuLi[widgetName]
  122.       else
  123.         props[#value] = valuLi[countCRPG]
  124.       end if
  125.     end if
  126.     if getOne([#e, #s], typ) then
  127.       if typ = #e then
  128.         countE = countE + 1
  129.         curName = props[#title]
  130.         nowName = curName && countE
  131.         props[#title] = nowName
  132.       end if
  133.       props[#value] = textList[i - countImg]
  134.       if typ = #s then
  135.         txt = getReplacedText(txt, returnSubst, RETURN)
  136.       end if
  137.     else
  138.       if typ = #i then
  139.         countImg = countImg + 1
  140.         if countBtn = 0 then
  141.           countImgBeforeBtn = countImgBeforeBtn + 1
  142.         end if
  143.         iconTyp = getPropAt(iconLi, countImg)
  144.         if (iconTyp = #mem) or (iconTyp = #GUI) then
  145.           if (the activeWindow = the stage) or (iconTyp = #GUI) then
  146.             theMem = iconLi[countImg]
  147.           else
  148.             preview = "IconPreview" && countImg
  149.             theMem = member(preview)
  150.           end if
  151.           if iconTyp = #mem then
  152.             stageMem = iconLi[countImg]
  153.             noMem = getNoStageMem(stageMem)
  154.             if noMem then
  155.               Info = ["Missing", "Wrong"][noMem]
  156.               alert(Info && "member for icon:" & RETURN & stageMem)
  157.             end if
  158.           end if
  159.           props[#value] = theMem
  160.         end if
  161.       else
  162.         if getOne([#d, #b, #c, #r], typ) > 0 then
  163.           props[#title] = textList[i - countImg]
  164.         else
  165.           props[#title] = "Unnamed"
  166.         end if
  167.       end if
  168.     end if
  169.     case typ of
  170.       #e, #s:
  171.         attr = [#textAlign: alignList[i]]
  172.         if styleList[i] <> 0 then
  173.           attr[#textSize] = styleList[i]
  174.         end if
  175.         props[#Attributes] = attr
  176.       #i:
  177.         if getPropAt(iconLi, countImg) = #sys then
  178.           props[#Attributes] = [#bitmapIcon: iconLi[countImg]]
  179.         end if
  180.       #p:
  181.         attr = attrLi.getProp(i)
  182.         props[#title] = "Pop"
  183.         if attr.count = 0 then
  184.           attr = ["<No values>"]
  185.         end if
  186.         props[#Attributes] = [#valueList: attr]
  187.       #G:
  188.         attr = attrLi.getProp(i)
  189.         styleAttr = attr[#sliderStyle]
  190.         sliderTyp = attr[#sliderTyp]
  191.         RangeAttr = attr[#valueRange]
  192.         muiAttr = [#valueRange: [#min: RangeAttr[1], #max: RangeAttr[2]], #increment: RangeAttr[3], #jump: RangeAttr[4], #acceleration: RangeAttr[5], #sliderStyle: styleAttr]
  193.         props[#type] = sliderTyp
  194.         props[#Attributes] = muiAttr
  195.     end case
  196.     add(gMUIGUIVars[#MUIItemsLi], props)
  197.     add(gMUIGUIVars[#MUIWidgetsLi], props)
  198.     if typ = #r then
  199.       if closeGroupAtWidgetNum = i then
  200.         add(gMUIGUIVars[#MUIItemsLi], groupVClose)
  201.         closeGroupAtWidgetNum = 0
  202.       end if
  203.     end if
  204.     if getOne([#e, #p, #G, #c, #r], typ) > 0 then
  205.       gMUIGUIVars[#MUIOutputLi][props[#name]] = props[#value]
  206.     end if
  207.   end repeat
  208.   add(gMUIGUIVars[#MUIItemsLi], winClose)
  209.   Initialize(gMUIObj, [#windowPropList: MuiWindowProps, #windowItemList: gMUIGUIVars[#MUIItemsLi]])
  210.   clickElemNum = Run(gMUIObj)
  211.   if MuiWindowProps.modal then
  212.     if clickElemNum < 0 then
  213.       alert("MUI-Error. Return value =" && QUOTE & clickElemNum & QUOTE)
  214.       return [-1]
  215.     else
  216.       if clickElemNum = 0 then
  217.         gMUIObj = 0
  218.         return [0]
  219.       else
  220.         BtnProps = gMUIGUIVars[#MUIItemsLi][clickElemNum]
  221.         txt = BtnProps[#title]
  222.         gMUIObj = 0
  223.         return [clickElemNum - countImgBeforeBtn - 1, txt, gMUIGUIVars[#MUIOutputLi]]
  224.       end if
  225.     end if
  226.   else
  227.     WindowOperation(gMUIObj, #show)
  228.   end if
  229. end
  230.  
  231. on muiCallbackStandard event, eventData, itemPropList
  232.   if not symbolp(event) then
  233.     exit
  234.   end if
  235.   typ = itemPropList[#type]
  236.   currName = gMUIGUIVars[#MUIItemsLi][eventData][#name]
  237.   currNum = gMUIGUIVars[#MUIItemsLi][eventData][#realNum]
  238.   val = itemPropList[#value]
  239.   case event of
  240.     #itemChanged:
  241.       if typ = #radioButton then
  242.         muiCallBackRadiobuttonBehavior(currName, currNum)
  243.       else
  244.         gMUIGUIVars[#MUIOutputLi][currName] = val
  245.       end if
  246.     #itemClicked:
  247.       if (typ = #defaultPushButton) or (typ = #pushButton) then
  248.         muiKillDialog(eventData, currName)
  249.       end if
  250.   end case
  251. end
  252.  
  253. on muiKillDialog eventData, widName
  254.   if gMUIGUIVars[#modal] then
  255.     stop(gMUIObj, eventData)
  256.   else
  257.     gMUIGUIVars[#MUIOutputLi][widName] = #muiClosed
  258.     WindowOperation(gMUIObj, #Hide)
  259.   end if
  260. end
  261.  
  262. on muiCallBackRadiobuttonBehavior currName, currNum
  263.   repeat with i = 1 to gMUIGUIVars[#radioGroupWidgets].count
  264.     grp = gMUIGUIVars[#radioGroupWidgets].getPropAt(i)
  265.     rds = gMUIGUIVars[#radioGroupWidgets][i]
  266.     Pos = getOne(rds, currNum)
  267.     if Pos > 0 then
  268.       repeat with widget in rds
  269.         theName = gMUIGUIVars[#MUIWidgetsLi][widget][#name]
  270.         gMUIGUIVars[#MUIOutputLi][theName] = 0
  271.       end repeat
  272.       gMUIGUIVars[#MUIOutputLi][currName] = 1
  273.       exit repeat
  274.     end if
  275.   end repeat
  276. end
  277.  
  278. on getEmptyMUIPropList typ
  279.   case typ of
  280.     #d:
  281.       return [#value: EMPTY, #type: #defaultPushButton, #Attributes: [], #title: EMPTY, #tip: "tip", #locH: 0, #locV: 0, #width: 0, #height: 0, #enabled: 1]
  282.     #b:
  283.       return [#value: EMPTY, #type: #pushButton, #Attributes: [], #title: EMPTY, #tip: "tip", #locH: 0, #locV: 0, #width: 0, #height: 0, #enabled: 1]
  284.     #s:
  285.       return [#value: EMPTY, #type: #label, #Attributes: [], #title: "S", #tip: "tip", #locH: 0, #locV: 0, #width: 0, #height: 0, #enabled: 1]
  286.     #e:
  287.       return [#value: EMPTY, #type: #editText, #Attributes: [], #title: "E", #tip: "tip", #locH: 0, #locV: 0, #width: 0, #height: 0, #enabled: 1]
  288.     #i:
  289.       return [#value: 0, #type: #bitmap, #Attributes: [], #title: "Icon", #tip: "tip", #locH: 0, #locV: 0, #width: 0, #height: 0, #enabled: 1]
  290.     #c:
  291.       return [#value: 0, #type: #checkBox, #Attributes: [], #title: EMPTY, #tip: "Tip", #locH: 0, #locV: 0, #width: 0, #height: 0, #enabled: 1]
  292.     #r:
  293.       return [#value: 0, #type: #radioButton, #Attributes: [], #title: EMPTY, #tip: "Tip", #locH: 0, #locV: 0, #width: 0, #height: 0, #enabled: 1]
  294.     #p:
  295.       return [#value: EMPTY, #type: #PopupList, #Attributes: [], #title: EMPTY, #tip: "tip", #locH: 0, #locV: 0, #width: 0, #height: 0, #enabled: 1]
  296.     #G:
  297.       return [#value: 0, #type: #IntegerSliderH, #Attributes: [], #title: EMPTY, #tip: "tip", #locH: 0, #locV: 0, #width: 0, #height: 0, #enabled: 1]
  298.     #H:
  299.       return [#value: EMPTY, #type: #dividerH, #Attributes: [], #title: EMPTY, #tip: "tip", #locH: 0, #locV: 0, #width: 0, #height: 0, #enabled: 1]
  300.     #V:
  301.       return [#value: EMPTY, #type: #dividerV, #Attributes: [], #title: EMPTY, #tip: "tip", #locH: 0, #locV: 0, #width: 0, #height: 0, #enabled: 1]
  302.   end case
  303. end
  304.  
  305. on getMUIGUIDlogText BtnsLi, StatLi, EditLi
  306.   inscription = []
  307.   repeat with i = 1 to BtnsLi.count
  308.     add(inscription, BtnsLi[i])
  309.   end repeat
  310.   repeat with i = 1 to EditLi.count
  311.     add(inscription, EditLi[i])
  312.   end repeat
  313.   repeat with i = 1 to StatLi.count
  314.     add(inscription, StatLi[i])
  315.   end repeat
  316.   return inscription
  317. end
  318.  
  319. on getMuiIconSize iconLi, iNum, mode
  320.   if mode = #x then
  321.     return member(iconLi[iNum]).width
  322.   else
  323.     return member(iconLi[iNum]).height
  324.   end if
  325. end
  326.  
  327. on getReplacedText givenTxt, searchString, newString
  328.   repeat while givenTxt contains searchString
  329.     c = offset(searchString, givenTxt)
  330.     put newString into char c to c + the length of searchString - 1 of givenTxt
  331.   end repeat
  332.   return givenTxt
  333. end
  334.  
  335. on getNoStageMem theMem
  336.   if theMem = 0 then
  337.     return 1
  338.   end if
  339.   tell the stage
  340.     if theMem.type = #empty then
  341.       return 1
  342.     end if
  343.     if theMem.type <> #bitmap then
  344.       return 2
  345.     end if
  346.   end tell
  347.   return 0
  348. end
  349.  
  350. on getWindowCenterH
  351.   return (the activeWindow).rect.left + ((the activeWindow).rect.width / 2)
  352. end
  353.  
  354. on getWindowCenterV
  355.   return (the activeWindow).rect.top + ((the activeWindow).rect.height / 2)
  356. end
  357.